//
//  HMVisitorViewController.swift
//  Faner_Weibo
//
//  Created by 范英强 on 16/1/26.
//  Copyright © 2016年 范英强. All rights reserved.
//

import UIKit

class HMVisitorViewController: UITableViewController {

    var userLogin = HMUserAccountViewModel.sharedAccount.accountToken != nil
    
    var visitorView: HMVisitorView?
    
    override func loadView() {
        userLogin ? setLoginBarButtonItem() : setupUI()
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    
    private func setupUI(){
        print(self)
        visitorView = HMVisitorView()
        visitorView?.registerButton.addTarget(self, action: "login", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "login", forControlEvents: UIControlEvents.TouchUpInside)
//        visitorView?.delegate = self
        
        
        //判断哪个

        if self .isKindOfClass(HMHomeTableViewController.self) {
           visitorView?.setVisitorInfo(nil, title: nil)
        }else if self.isKindOfClass(HMMessageTableViewController.self){
           visitorView?.setVisitorInfo("visitordiscover_image_message", title: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }else if self.isKindOfClass(HMDiscoverTableViewController.self){
           visitorView?.setVisitorInfo("visitordiscover_image_message", title: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }else{
           visitorView?.setVisitorInfo("visitordiscover_image_profile", title: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        let aa = HMDiscoverTableViewController.classForCoder
        print(aa)
        
        if self.classForCoder == HMVisitorViewController.classForCoder(){
            
        }
        view = visitorView
        //设置左边右边按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", target: self, action: "login")
        tableView = UITableView()
    }

    func setLoginBarButtonItem() {
        super.loadView()
        
    }
//    
//    // MARK: - delegate
//    func loginButtonClick() {
//      print("登陆")
//    }
//    
//    func registerButtonClick() {
//       print("注册")
//    }
    // MARK: - 逻辑处理
    @objc private func login(){
        print("登陆")
        let vc = HMOAuthViewController()
        let oauthVc = HMNavigationController(rootViewController: vc)
        presentViewController(oauthVc, animated: true, completion: nil)
    }
    
    
}


